package algorithm.leecode.combination;
import java.util.HashMap;
import java.util.Map;

/**
 * @author bingo
 * @Description  给定一个数字，求这个数字对应收键盘上字母的所有可能组合
 * @Date 2018/9/4
 */
public class PhoneNumber {

    private int count = 0;

    public int getCount() {
        return count;
    }

    private Map<Integer,String> map = new HashMap<>();

    {
         map.put(0," ");
         map.put(1,"");
         map.put(2,"abc");
         map.put(3,"def");
         map.put(4,"ghi");
         map.put(5,"jkl");
         map.put(6,"mno");
         map.put(7,"pqrs");
         map.put(8,"tuv");
         map.put(9,"wxyz");
    }

     private void  generation(int startInex,int[] digits,String s){
         System.out.println("startIndex------:"+startInex);
        if(startInex==digits.length){
            count++;
            System.out.println(s);
            return;
        }
        String letter = map.get(digits[startInex]);
        for(int i=0;i<letter.length();i++){
            System.out.println("letter.chatAt(i):"+letter.charAt(i));
            generation(startInex+1,digits,s+letter.charAt(i));
        }

     }

     public void get(int[] digits){

        generation(0,digits,"");
    }

    public static void main(String[] args) {
        PhoneNumber phoneNumber = new PhoneNumber();
        phoneNumber.get(new int[]{2,3,9});
        System.out.println(phoneNumber.getCount());
    }
}
